﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lenovo.CFI.DicMgr;

namespace Lenovo.CFI.Common.Dic
{
    public class Keyword : DataDictionaryEntry
    {
        #region .ctor

        /// <summary>
        /// </summary>
        public Keyword()
            : base()
        { }

        public Keyword(string code, string title, int sort, bool visible, string updator, DateTime updateTime)
            : base(code, title, sort, visible, updator, updateTime)
        {
        }

        #endregion

        #region fields

        #endregion

        #region properity

        #endregion

        #region IComparable Members

        /// <summary>
        /// 比较当前对象和同一类型的另一对象。用于排序。
        /// </summary>
        /// <param name="obj">与此对象进行比较的对象。</param>
        /// <returns>一个 32 位有符号整数，指示要比较的对象的相对顺序。</returns>
        /// <remarks>也可以添加一个范型实现。</remarks>
        public override int CompareTo(object obj)
        {
            if (obj is Keyword)
            {
                Keyword temp = (Keyword)obj;

                int s = this.Sort.CompareTo(temp.Sort);

                if (s == 0) return this.Code.CompareTo(temp.Code);
                else return s;
            }

            throw new ArgumentException("object is not a Keyword");
        }

        /// <summary>
        /// 比较当前对象和同一类型的另一对象。用于排序。
        /// </summary>
        /// <param name="other">与此对象进行比较的对象。</param>
        /// <returns>一个 32 位有符号整数，指示要比较的对象的相对顺序。</returns>
        public int CompareTo(Keyword other)
        {
            int s = this.Sort.CompareTo(other.Sort);

            if (s == 0) return this.Code.CompareTo(other.Code);
            else return s;
        }

        #endregion

        #region 支持非立即、可撤销更新

        #endregion
    }
}
